package com.sss.hloster03;

public class TestFor01 {

	public static void main(String[] args) {
		test06();

	}
	/**
	 * 问号表达式
	 */
	private static void test06() {
		System.out.println("============================");
       int score =100;
       String str = score >=90?"优秀":"需要努力";
       System.out.println("成绩："+str);
		System.out.println("============================");
       int score1 = 80;
       String str1 = score1>90?"优秀":
    	                score1>80?"良好":
    	                	score1>70?"中等":
    	                		score1>60?"及格":"不及格";
    	   System.out.println("成绩：" + str1);
	
	
	}
	
	
	
	/**
	 * switch语句
	 */
	private static void test05() {
		System.out.println("============================");
	int score = 100;
	//如果除法运算的结果为整形，则会舍弃小数点部分；
	int scoreGrade = score /10;
	switch(scoreGrade) {
	case 10:
	case 9:
	System.out.println("优秀");
	break;
	case 8:
		System.out.println("良好");
		break;
	case 7:
		System.out.println("中等");
		break;
	case 6:
		System.out.println("合格");
		break;
	default:
		System.out.println("不及格");
	   }
	System.out.println("============================");
	int score1 = 100;
	//如果除法运算的结果为整形，则会舍弃小数点部分；
	int scoreGrade1 = score /10;
	switch(scoreGrade1) {
	default:
		System.out.println("不及格");
		break;
	case 10:
	case 9:
	System.out.println("优秀");
	break;
	case 8:
		System.out.println("良好");
		break;
	case 7:
		System.out.println("中等");
		break;
	case 6:
		System.out.println("合格");
		break;
	
	   }
	}
	/**
	 * do-while循环
	 */
	private static void test04() {
		System.out.println("============================");
		//循环因子初始化赋值
		int i = 0;
		do {
			System.out.print(" "+i);
			//每十个元素进行换行
			if ((i+1)% 10 == 0) {
				//换行
				System.out.println();
			}
	        //改变循环因子
			i++;
		}
		while(i <100);
		
		System.out.println("=========================");
		int j =-1;
		do {
			System.out.print(" "+j);
			//每10个元素进行换行
			if((j+1)%10 ==0) {
				//换行
				System.out.println();
			}
		}while(++j < 100);
	}
	/**
	 * while循环
	 */
	private static void test03() {
		System.out.println("============================");
		//循环因子初始化赋值
		int i =0;
		while (i<100) {
			System.out.print(" "+ i);
			//每10个元素进行换行
			if ((i+1)% 10 == 0) {
				//换行
				System.out.println();
		}//改变循环因子
		i++;
	 }
		System.out.println("========================");
		int j = -1;
		//使用自增，自减表达式，在循环判断条件中，改变循环因子
		while (++j < 100) {
			System.out.print(" "+ j);
			//每10个元素进行换行
			if((j + 1)% 10 ==0) {
				//换行
				System.out.println();
			}
			
		}
	}	
	
/**
 * for循环
 */
	private static void test02() {
		System.out.println("============================");
		for (int i = 0;i<100;i++) {
			System.out.print(" "+i);
		}
		System.out.println("\n============================");
		int i=0;
		for(;i<100;i++) {
			System.out.print(" "+i);
		}
		System.out.println("\n=========================");
		int j = 0;
		for(;j<100;) {
			System.out.print(" "+j);
			j++;
		}
		System.out.println("\n=========================");
		
			
		}
	
	/**
	 * if分支语句
	 */
	private static void test01() {
		int score = 90;
		//if分支
		if(score >=90) {
			System.out.println("优秀");
		}
		System.out.println("====================");
		//if双分支
		if(score >=90) {
			System.out.println("优秀");
		}else {
			System.out.println("请继续努力");
		}
		System.out.println("===================");
		//if多分支
		if (score >=90) {
			System.out.println("优秀");
		}else if(score >=80) {
			System.out.println("良好");
		}else if(score >=70) {
			System.out.println("中等");
		}else if(score >=80) {
				System.out.println("及格");
	}else  {
		System.out.println("不及格");
		}System.out.println("=============");
		if(score >=90) {
			;
			System.out.println("优秀");
			System.out.println("执行完毕");
		}
	}
}
